const CopyPlugin = require('copy-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('path');

module.exports = {
  // 配置环境
  mode: 'development',

  devtool: 'source-map',

  // 配置入口
  entry: {
    app: './src/app.js'
  },

  // 配置出口
  output: {
    path: path.join(__dirname, './dist'),
    filename: 'app.js'
  },

  // 配置插件
  plugins: [
    new HtmlWebpackPlugin({
      template: './public/index.html',
      filename: 'index.html'
    }),
    new CopyPlugin({
      patterns: [
        {
          from: 'public/*ico'
          
        }
      ]
    })
  ],

  // 配置server
  devServer: {
    contentBase: path.join(__dirname, './dist'),
    compress: true,
    port: 8080
  }
}